/*
 * Copyright (C) 2019 ByteDance Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bytedance.scene.animation.interaction.scenetransition.utils;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.Image;
import ohos.agp.utils.Matrix;

/**
 * Created by JiangQi on 10/23/18.
 */
public class SceneViewCompatUtils {
    interface SceneViewCompatUtilsImpl {
        void setLeftTopRightBottom(Component v, int left, int top, int right, int bottom);

        void animateTransform(Image view, Matrix matrix);

        float getTransitionAlpha(Component view);

        void setTransitionAlpha(Component view, float alpha);

        void suppressLayout(ComponentContainer group, boolean suppress);

        void transformMatrixToGlobal(Component view, Matrix matrix);

        void transformMatrixToLocal(Component view, Matrix matrix);

        void setAnimationMatrix(Component view, Matrix matrix);
    }

    private static final SceneViewCompatUtilsImpl IMPL;

    static {

        IMPL = new SceneViewCompatUtilsApi22();
//            IMPL = new SceneViewCompatUtilsApi21();
    }

    public static void setLeftTopRightBottom(Component v, int left, int top, int right, int bottom) {
        IMPL.setLeftTopRightBottom(v, left, top, right, bottom);
    }

    public static void animateTransform(Image view, Matrix matrix) {
        IMPL.animateTransform(view, matrix);
    }

    public static float getTransitionAlpha(Component view) {
        return IMPL.getTransitionAlpha(view);
    }

    public static void setTransitionAlpha(Component view, float alpha) {
        IMPL.setTransitionAlpha(view, alpha);
    }

    public static void suppressLayout(ComponentContainer group, boolean suppress) {
        IMPL.suppressLayout(group, suppress);
    }

    public static void transformMatrixToGlobal(Component view, Matrix matrix) {
        IMPL.transformMatrixToGlobal(view, matrix);
    }

    public static void transformMatrixToLocal(Component view, Matrix matrix) {
        IMPL.transformMatrixToLocal(view, matrix);
    }

    public static void setAnimationMatrix(Component view, Matrix matrix) {
        IMPL.setAnimationMatrix(view, matrix);
    }
}
